package com.maple.web.controller.common;

import com.alibaba.fastjson.JSONObject;
import com.maple.common.config.Global;
import com.maple.common.core.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 首页 业务处理
 *
 * @author ruoyi
 */
@Controller
public class SysIndexController extends BaseController {

    // 系统首页
    @GetMapping("/index")
    public String index(ModelMap mmap) {
        List<JSONObject> menus = new ArrayList<>();
        JSONObject gen = JSONObject.parseObject("    {\n" +
                "        \"createBy\": \"admin\",\n" +
                "        \"createTime\": \"2023-11-23 21:19:59\",\n" +
                "        \"updateBy\": null,\n" +
                "        \"updateTime\": null,\n" +
                "        \"remark\": null,\n" +
                "        \"menuId\": 115,\n" +
                "        \"menuName\": \"代码生成\",\n" +
                "        \"parentName\": null,\n" +
                "        \"parentId\": 0,\n" +
                "        \"orderNum\": \"2\",\n" +
                "        \"url\": \"/tool/gen\",\n" +
                "        \"target\": \"\",\n" +
                "        \"menuType\": \"C\",\n" +
                "        \"visible\": \"0\",\n" +
                "        \"isRefresh\": \"1\",\n" +
                "        \"perms\": \"tool:gen:view\",\n" +
                "        \"icon\": \"fa fa-code\",\n" +
                "        \"children\": []\n" +
                "    }");
        menus.add(gen);
        mmap.put("menus", menus);
        JSONObject user = JSONObject.parseObject(" {\n" +
                "            \"createBy\": \"admin\",\n" +
                "            \"createTime\": \"2023-11-23 21:19:59\",\n" +
                "            \"updateBy\": null,\n" +
                "            \"updateTime\": null,\n" +
                "            \"remark\": \"管理员\",\n" +
                "            \"userId\": 1,\n" +
                "            \"deptId\": 103,\n" +
                "            \"parentId\": null,\n" +
                "            \"roleId\": null,\n" +
                "            \"loginName\": \"admin\",\n" +
                "            \"userName\": \"若依\",\n" +
                "            \"userType\": \"00\",\n" +
                "            \"email\": \"ry@163.com\",\n" +
                "            \"phonenumber\": \"15888888888\",\n" +
                "            \"sex\": \"1\",\n" +
                "            \"avatar\": \"\",\n" +
                "            \"status\": \"0\",\n" +
                "            \"delFlag\": \"0\",\n" +
                "            \"loginIp\": \"111.196.132.228\",\n" +
                "            \"loginDate\": \"2024-05-31 12:11:18\",\n" +
                "            \"pwdUpdateDate\": null,\n" +
                "            \"dept\": {\n" +
                "                \"createBy\": null,\n" +
                "                \"createTime\": null,\n" +
                "                \"updateBy\": null,\n" +
                "                \"updateTime\": null,\n" +
                "                \"remark\": null,\n" +
                "                \"deptId\": 103,\n" +
                "                \"parentId\": null,\n" +
                "                \"ancestors\": null,\n" +
                "                \"deptName\": \"研发部门\",\n" +
                "                \"orderNum\": null,\n" +
                "                \"leader\": \"若依\",\n" +
                "                \"phone\": null,\n" +
                "                \"email\": null,\n" +
                "                \"status\": null,\n" +
                "                \"delFlag\": null,\n" +
                "                \"parentName\": null\n" +
                "            },\n" +
                "            \"roles\": [],\n" +
                "            \"roleIds\": null,\n" +
                "            \"postIds\": null,\n" +
                "            \"admin\": true\n" +
                "        }");
        mmap.put("user", user);
        mmap.put("copyrightYear", Global.getCopyrightYear());
        mmap.put("demoEnabled", Global.isDemoEnabled());
        return "index";
    }

    // 切换主题
    @GetMapping("/system/switchSkin")
    public String switchSkin(ModelMap mmap) {
        return "skin";
    }

    // 系统介绍
    @GetMapping("/system/main")
    public String main(ModelMap mmap) {
        mmap.put("version", Global.getVersion());
        return "main";
    }
}